from django.conf.urls import url

from django.contrib.auth.decorators import login_required

from . import views
urlpatterns = [
    #注册接收数据、校验、贮存数据
    url(r'^register/$',views.RegisterUser.as_view(),name='register'),

    #用户名重复
    url(r'^usernames/(?P<username>[a-zA-Z0-9_-]{5,20})/count/$',views.UserRegisterView.as_view(),name='usernames'),

    #密码重复
    url(r'^mobile/(?P<mobile>1[345789]\d{9})/count/$',views.MobilRegisterView.as_view(),name='mobile'),

    #登录页面
    url(r'^login/$', views.LoginView.as_view(),name='login'),

    #退出登录
    url(r'^logout/$', views.LoginOutView.as_view(),name='loginout'),

    #方法二：用django的装饰器login_requried装饰as_view()的返回值
    #用django的装饰器login_required装饰入口函数as_view()判断用户是否登录,
    # 登录访问指定页面，未登录返回LOGIN_URL=[/account/info/]django 配置指定的页面，在dev修改配置返回自己的页面
    # url(r'info/$',login_required(views.UserInfo.as_view()),name='info'),

    url(r'^info/$', views.UserInfo.as_view(),name='info'),


]